package com.shang.core;

import com.shang.core.base.Meta;
import com.shang.core.base.PadPosition;
import com.shang.core.base.Value;

import javax.xml.bind.DatatypeConverter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * Created by shangwei2009@hotmail.com on 2021/9/8 10:38
 */
public class StringValue extends Value {

    public StringValue(Meta meta) {
        this(meta, StandardCharsets.US_ASCII);
    }

    public StringValue(Meta meta, Charset charset) {
        super(meta, charset, PadPosition.NONE, "");
    }

    @Override
    protected String valueStr(String valueStr) {
        return new String(DatatypeConverter.parseHexBinary(valueStr), charset);
    }
}
